home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ASSEMBLER / EXTASM / !extASM / !Manual < prev    next >
Text File  |  1993-11-22  |  16KB  |  425 lines

  1. =====================================================================
  2.                    extASM v0.50 - Users Manual
  3. =====================================================================
  4.  
  5. Introduction
  6. ------------
  7. extASM is an extended assembler for ARM RISC Processors.
  8. • Complete ARM 2 and FPA10 instruction set.
  9. • Interactive WIMP interface & WIMP batch processing.
  10. • Smart auto-expanding instruction-set.
  11.  
  12. How to use
  13. ----------
  14. WIMP Batch: Start from an Obey-file,
  15. Syntax:    <extASM$Dir>.!RunImage <infile> <outfile>
  16. Where:    infile is the source filename.
  17.         outfile is the object filename (executable).
  18. Notice:    Some editors (e.g. StrongED) can be programmed to start
  19.         the assembly-process in this manner (F10 in StrongED).
  20.  
  21.  
  22. Interactive WIMP Interface: Double click on the application,
  23. Drag:    Drag the source file to the icon-bar icon to load.
  24.         You can also drag the source into the PROCESS window.
  25. Icon:    SELECT - Open PROCESS window
  26.         MENU - Open menu
  27.         ADJUST - Open Status-info window
  28. Status info:    All messages appear here!
  29. PROCESS:    Start - Invoke the assembler process
  30.         Source box:
  31.             Icon - no effect yet
  32.             Save - no effect yet
  33.         Object box:
  34.             Icon - drag to save
  35.             Save - press to save
  36.             Type - no effect yet
  37.             Name - edit this if you want another output-name
  38.  
  39. Switches (in source code)
  40. -------------------------
  41. Switch syntax            Meaning                                        Default
  42. ____________________________________________________________________________
  43. #name <objectname>        Set name of objet file                        [OBJECT]
  44. #type <filetype>        Set type of object file                        [&ff8]
  45. #base <address>            Set base address for assembly                [&8000]
  46. #load <address>            Set object load address (type must be 0)    [-1]
  47. #exec <address>            Set object exec address (type must be 0)    [-1]
  48. #smile                    Gives a smile when life is good :-)            [off]
  49. #speed <lines>            Set # of lines to assemble each Wimp-Poll    [64]
  50. #include <filename>        Includes another source file, like in C.
  51. #append <filename>        Append another source file at the end.
  52. #set <var> = <expr>        Set value of <var> to that of <expr>
  53.                         (#set is ignored by the preprocessor, and is
  54.                         actually handled by the assembler)
  55. #rept <num>                Repeat code num times
  56. #endr                    End of code to be repeated (after a #rept)
  57. #if <expression>        Assemble code if <expression> if TRUE
  58. #else                    Assemble from here when #if was FALSE
  59. #endif                    End #if / #else conditional assembly
  60. #error "<errorstring>"    Report some error in the status-info window
  61. #quit                    Quit extASM if there were no problems        [off]
  62.                         (quit after whole assembly is done)
  63.  
  64. Alignment of Code & Data
  65. ------------------------
  66. ALIGN    Set the object-pointer to a word boundary (32 bit).
  67.  
  68. Syntax:    ALIGN
  69. Notice:    The assembler will issue warnings if code is not word-aligned,
  70.         but it will not warn if data is not word-aligned (bytes...).
  71.  
  72. Examples of use:
  73.  
  74. align
  75.  
  76. Constant Declarations
  77. ---------------------
  78. DCB    Declare Constant Byte, also used for strings.
  79. DCW    Declare Constant Word (16 bit).
  80. DCD    Declare Constant Doubleword (32 bit).
  81.  
  82. Syntax:        <DCB | DCW | DCD> [Cost] {, Const}
  83. Special:    DCB [Const | String] {, Const | String}
  84. Where:        Const is any legal expression.
  85.             String is any string of characters enclosed in quotes (").
  86. Notice:        String may not contain the quote character ("), use constant 34.
  87.  
  88. Examples of use:
  89.  
  90. dcb   0
  91. dcb   1, 2, 3
  92. dcb   "Text", 0, "More text", 10, 13, 0
  93. dcq   10000, 20000, 30000, 101, 102, 103
  94. dcd   -1, -2, -3, 1<<16, 1<<24, 1<<30
  95. dcd   Label_1, Label_4-Label_3, &8000+Offset_to_something
  96.  
  97. Block Declarations
  98. ------------------
  99. DBB    Declare Block of Bytes.
  100. DBW    Declare Block of Words (16 bit).
  101. DBD    Declare Block of Doublewords (32 bit).
  102.  
  103. Syntax:    <DBB | DBW | DBD> Size [, Pattern]
  104. Where:    Size is how many items in the block (bytes, words or doubles).
  105.         Pattern is the value of each item, default = 0.
  106.  
  107. Examples of use:
  108.  
  109. dbb   1024, &ff
  110. dbw   100, %0110110101010100
  111. dbd   512
  112.  
  113. Including binary files (data-files)
  114. -----------------------------------
  115. INCBIN    Include Binary file.
  116.  
  117. Syntax:    INCBIN <filename>
  118. Where:    filename is the data-file to insert.
  119. Notice:    Space is automatically allocated for the file, and is byte-aligned.
  120.  
  121. Examples of use:
  122.  
  123. .SinTab    incbin   <tmp$path>.Tables.SinusTable
  124.  
  125. Case sensitivity
  126. ----------------
  127. All assembler syntax is case insensitive.
  128. All macros, labels & assembler variables are case sensitive.
  129.  
  130. Register binding
  131. ----------------
  132. Registers (r0-r15 or f0-f7) can be types in several ways:
  133.  
  134. • Using the hard-coded "r0"-"r15" or "f0"-"f7".
  135. • By typing any number, e.g. "8", "%0011", "&a" or similar.
  136. • By using a variable defined by #set, e.g. "MyReg", "Result".
  137. • In macros, "m0"-"mn".
  138.  
  139. Operators
  140. ---------
  141. The following operators are implemented:
  142. *            Multiplication            /            Division
  143. +            Addition                -            Subtraction
  144. <<            Shift left                EOR            Exclusive OR
  145. (            Start Sub-expression    )            End Sub-expression
  146. ==            Test for equal            != or <>    Test for not-equal
  147. <= or =<    Test for less-or-equal    >= or =>    Test for greater-or-equal
  148. >            Test for less-then        >            Test for greater-then
  149.     
  150. Extensions
  151. ----------
  152. extASM has been extended in many ways to offer greater value :
  153.  
  154. The instruction ORR can be spelled OR if you prefer.
  155. Hex numbers can be preceded with either "&" or the widely used "$".
  156. Octal values are supported, and should be preceded with "@".
  157. All labels start with a dot (.) as usual, but
  158. Local labels start their name with underscore (_). e.g. "._Loop"
  159. Most ALU instructions will be auto-expanded if the immediate constant is too big to be handled by a single instruction. The only instructions that cannot be auto-expanded are CMP, CMN, TST & TEQ. Future versions will provide these through the use of temp-registers.
  160. LDR & STR using labels will be auto-expanded if the 4KB range is exceeded, and will give a new range of 1MB. >1MB ranges might be implemented at a later date, but this should not be necessary, most executables are well below 1MB.
  161. TEMP & LOCK are used to tell the assembler that some registers can be temporarily used by macros or for auto-expanding, eliminating the need to save registers on the stack when extra registers are needed.
  162.  
  163. Local Labels
  164. ------------
  165. Local labels are very useful in assembler programming, because they make it possible to use the same label-name many times. When defining a local label, the first character of the label-name should be an underscore (_). The scope of the local label (where it is legal) is only between two normal variables. Here is an example:
  166.  
  167. .Skip_Blanks               ; R0 = char, R10-> next char
  168.    STMFD    R13!,{R14 }
  169. ._Loop                     ; define local label
  170.    CMP      R0,#" "        ; search for space-char
  171.    CMPNE    R0,#&09        ; ... or a TAB-char
  172.    LDREQB   R0,[R10],#1
  173.    BEQ      _Loop          ; use local label
  174.    LDMFD    R13!,{PC}^
  175.  
  176. Macros
  177. ------
  178. The use of macros make it easier to do routinely things, and can be a very powerful tool in making complex code. The macro can be defined anywhere in the source, and it is smart to have a standard file of all your standard macros, so that you can easily include this into all other programs you make.
  179. Currently, macros can take two different passing-parameters, and use three different parameter. The additional use-parameter is temp-registers.
  180.  
  181. The two passing-parameter types are:
  182.         Mx    Macro register (Mx = passed Rx)
  183.         Cx    Macro constant (Cx = passed constant)
  184.  
  185. The last use-only parameter is:
  186.         Tx    Macro temp-register.
  187.  
  188. The passing-parameters are the arguments sent from the source upon using the macro, and translates to the Mx/Cx inside the macro. The macro temp-regs are additional registers that the macro needs to do the job. The temp-registers will be allocated by the assembler automatically. Here's a simple macro example.
  189.  
  190. .Start
  191.    mov      r1,r2                     ; normal instruction
  192.    inc3     r1,r2,r8,128,256,512      ; use macro
  193.    movs     pc,r14
  194. .End
  195.  
  196. macro inc m0,m1,m2,c0,c1,c2           ; define macro
  197. {
  198.    add      m0,m0,#c0
  199.    add      m1,m1,#c1
  200.    add      m2,m2,#c2
  201. }
  202.  
  203. NOTE: You should not use any variables begining with "m" or "t" for register binding, as this will conflict with the "mx" & "tx" macro register alias. Also, do not use any constant-variables (or labels) starting with "c" as this will conflict with the "cx" macro constant alias.
  204. Future versions will implement macros in a different way - which will eliminate this problem.
  205.  
  206. Structures
  207. ----------
  208. Structures let you combine several data-types to make a complec data-type. Most high-level languages support such mechanisms, and now you can benefit from this usefull technique in assembly level programming as well.
  209.  
  210. Here's how to make a simple structure:
  211.  
  212. struct mouse {
  213.    .x_pos       dcd   0
  214.    .y_pos       dcd   0
  215.    .buttons     dcd   0
  216.    .size                             ; .size = size of struct! (end...)
  217. }
  218.  
  219. To allocate some static space for an instance of this data-type do this:
  220.  
  221. .MouseBlock
  222.    dbb   mouse.size,0                ; declare block or rigth size
  223.    align                             ; just in case it wasn't aligned...
  224.  
  225. Easy! Now, to address directly into this area, here's how:
  226.  
  227.    swi      OS_Mouse
  228.    str      r0,MouseBlock + mouse.x_pos
  229.    str      r1,MouseBlock + mouse.y_pos
  230.    str      r2,MouseBlock + mouse.buttons
  231.  
  232. Or, if you have a register pointing to the data-area, you can:
  233.  
  234.    swi      OS_Mouse
  235.    adr      r9,MouseBlock
  236.    str      r0,[r9,#mouse.x_pos]
  237.    str      r1,[r9,#mouse.y_pos]
  238.    str      r2,[r9,#mouse.buttons]
  239.  
  240. Extra Internal Instructions
  241. ---------------------------
  242. ADR    Get address.
  243.  
  244. Syntax:    ADR[CC]   Rd, <Label>
  245. Operation:    Rd = Address of <label>
  246.  
  247. Examples of use:
  248.  
  249. adr      r1,Data_Block
  250.  
  251. DIV    Integer division.
  252.  
  253. Syntax:    DIV[CC]   Rd, Rn, Rs
  254. Operation:    Rd = Rn DIV Rs
  255.             Rn = Rn MOD Rs
  256. Notice:    Rd, Rn & Rs must be uniqe.
  257. Extra:    Uses 1 Temp Register.
  258.  
  259. Examples of use:
  260.  
  261. div      r1,r4,r7
  262. divle    r10,r11,r12
  263.  
  264. EXG    Exhange contents of two integer registers.
  265.  
  266. Syntax:    EXG[CC][S]   Rd,Rn
  267. Operation:    Rd = old Rn
  268.             Rn = old Rd
  269. Notice:    Rd must be different from Rn.
  270.  
  271. Examples of use:
  272.  
  273. exg      r1,r2
  274. exglt    r3,r9
  275. exgnes   r0,r1
  276.  
  277. Temp Register Management
  278. ------------------------
  279. TEMP    Mark a register as unused, so it can be used as a TempReg
  280.  
  281. Syntax:    TEMP   RegList
  282. Where:    Reglist is a list of registers, or register-ranges.
  283. Notice:    The contents of Rd are unsafe until it is LOCK'ed again.
  284.  
  285. Examples of use:
  286.  
  287. temp   r0
  288. temp   r1,r2,r8-r12
  289.  
  290. LOCK    Reclaim a register after a it has been TEMP'ed.
  291.  
  292. Syntax:    LOCK   RegList
  293. Where:    Reglist is a list of registers, or register-ranges.
  294. Notice    The contents of Rd is safe after this point.
  295.  
  296. Examples of use:
  297.  
  298. lock   r0
  299. lock   r1,r2,r8-r12
  300.  
  301. Stack setup
  302. -----------
  303. The assembler assumes there is a valid full-descending stack at R13. This is for saving temporary registers during macros or auto-expansion of out-of-range instructions where no temp-regs are available.
  304.  
  305. Here is an example of how to setup a valid stack:
  306.  
  307. #set StackSize = 1024                  ; how large stack do we want?
  308. .Start
  309.    b        Main                       ; jump over the stack
  310. .Stack_Ceiling                         ; top-of-stack
  311.    dbb      StackSize,0                ; allocate stack space here
  312. .Stack_Floor                           ; bottom-of-stack
  313. .Old_Stack  dcd   0                    ; place to store old r13
  314. .Main
  315.    str      r13,Old_Stack              ; save old r13
  316.    adr      r13,Stack_Floor            ; r13-> new stack
  317.    stmfd    r13!,{r0-r12,r14}          ; push all registers on our stack
  318. .Begin
  319.    ;        normal code                ; put your program here
  320. .End
  321.    ldmfd    r13!,{r0-r12,r14}          ; pop all registers from our stack
  322.    ldr      r13,Old_Stack              ; get old r13
  323.    movs     pc,r14                     ; return with all registers intact
  324.  
  325. ARM2 Instruction Set
  326. --------------------
  327. B{CC}            Offset                        ; Branch
  328. BL{CC}            Offset                        ; Branch with link
  329.  
  330. MOV{CC}{S}        Rd, Op2                        ; Rd = Op2
  331. MVN{CC}{S}        Rd, Op2                        ; Rd = NOT Op2
  332.  
  333. AND{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 AND Op2
  334. EOR{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 EOR Op2
  335. OR{R}{CC}{S}    Rd, Op1, Op2                ; Rd = Op1 OR Op2
  336. BIC{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 AND NOT Op2
  337. SUB{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 - Op2
  338. RSB{CC}{S}        Rd, Op1, Op2                ; Rd = Op2 - Op1
  339. ADD{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 + Op2
  340. ADC{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 + Op2 + Carry
  341. SBC{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 - Op2 + Carry - 1
  342. RSC{CC}{S}        Rd, Op1, Op2                ; Rd = Op2 - Op1 + Carry - 1
  343.  
  344. TST{CC}{S}{p}    Op1, Op2                    ; Same as AND, but result is discarded
  345. TEQ{CC}{S}{p}    Op1, Op2                    ; Same as EOR, but result is discarded
  346. CMP{CC}{S}{p}    Op1, Op2                    ; Same as SUB, but result is discarded
  347. CMN{CC}{S}{p}    Op1, Op2                    ; Same as ADD, but result is discarded
  348.  
  349. MUL{CC}{S}        Rd, Op1, Op2                ; Rd = Op1 * Op2
  350. MLA{CC}{S}        Rd, Op1, Op2, Op3            ; Rd = Op1 * Op2 + Op3
  351.  
  352. LDR{CC}{B}{T}    Rd,<Address>                ; Rd = Data at <address> in memory
  353. STR{CC}{B}{T}    Rd,<Address>                ; Data at <address> in memory = Rd
  354. <Address> ::=     <expression>
  355.                 [Rn,<#expression>]{!}
  356.                 [Rn,{+/-}Rm{,<shift>}]{!}
  357.                 [Rn],<#expression>
  358.                 [Rn],{+/-}Rm{,<shift>}
  359.                 
  360.  
  361. LDM{CC}<PU>        Rn{!},<Reglist>{^}            ; Load Registers from Rn in memory
  362. STM{CC}<PU>        Rn{!},<Reglist>{^}            ; Store Registers to Rn in memory
  363. <PU> ::=        FD|ED|FA|EA|IA|IB|DA|DB
  364.  
  365. SWI{CC}        <expression>                    ; Perform a SoftWare Interrupt
  366.  
  367. FPA10 Instruction Set
  368. ---------------------
  369. LDF{CC}<S|D|E|P>    Fd,<Address>            ; Fd = Data at <address> in memory
  370. STF{CC}<S|D|E|P>    Fd,<Address>            ; Data at <address> in memory = Fd
  371. <Address> ::=    <expression>
  372.                 [Rn,<#expression>]{!}
  373.                 [Rn],<#expression>
  374.  
  375. LFM{CC}        Fd,<count>,<Address>            ; Load FP-Registers from <address>
  376. SFM{CC}        Fd,<count>,<Address>            ; Load FP-Registers from <address>
  377. <Address> ::=    <expression>
  378.                 [Rn,<#expression>]{!}
  379.                 [Rn],<#expression>
  380.  
  381. ADF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn + Fm
  382. MUF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn * Fm
  383. SUF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn - Fm
  384. RSF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fm - Fn
  385. DVF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn / Fm
  386. RDF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fm / Fn
  387. POW{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn raised to the power of (Fm)
  388. RPW{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fm raised to the power of (Fn)
  389. RMF{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Remainder of (Fn / Fm)
  390. FML{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn * Fm
  391. FDV{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fn / Fm
  392. FRD{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = Fm / Fn
  393. POL{CC}<S|D|E>{P|M|Z}    Fd,Fn,<Fm|#value>    ; Fd = polar angle of (Fn,Fm)
  394.  
  395. MVF{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = Fm
  396. MNV{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = - Fm
  397. ABS{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = ABS(Fm)
  398. RND{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = integer value of (Fm)
  399. SQT{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = square root of (Fm)
  400. LOG{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = log10 of (Fm)
  401. LGN{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = loge of (Fm)
  402. EXP{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = e raised to the power of Fm
  403. SIN{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = sine of (Fm)
  404. COS{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = cosine of (Fm)
  405. TAN{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = tangent of (Fm)
  406. ASN{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = arc-sine of (Fm)
  407. ACS{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = arc-cosine of (Fm)
  408. ATN{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = arc-tangent of (Fm)
  409. URD{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = unnormalised round of (Fm)
  410. NRM{CC}<S|D|E>{P|M|Z}    Fd,<Fm|#value>        ; Fd = normalise (Fm) (after URD)
  411. <#value> ::=    0.0 | 0.5 | 1.0 | 2.0 | 3.0 | 4.0 | 5.0 | 10.0
  412.  
  413. FLT{CC}<S|D|E>{P|M|Z}    Fn, Rd                ; Fn = Rd
  414. FIX{CC}<S|D|E>{P|M|Z}    Rd, Fm                ; Rd = Fm
  415. WFS{CC}<S|D|E>{P|M|Z}    Rd                    ; FPSR = Rd
  416. RFS{CC}<S|D|E>{P|M|Z}    Rd                    ; Rd = FPSR
  417. WFC{CC}<S|D|E>{P|M|Z}    Rd                    ; FPCR = Rd (SVC mode only)
  418. RFC{CC}<S|D|E>{P|M|Z}    Rd                    ; Rd = FPCR (SVC mode only)
  419.  
  420. CMF{CC}            Fn,Fm                        ; compare Fn with Fm (for EQ or NE)
  421. CNF{CC}            Fn,Fm                        ; compare Fn with -Fm (for EQ or NE)
  422. CMFE{CC}        Fn,Fm                        ; compare Fn with Fm (for GT,GE,LT,LE)
  423. CNFE{CC}        Fn,Fm                        ; compare Fn with -Fm (for GT,GE,LT,LE)
  424.  
  425.